namespace Baula.TextGen.ActiveTemplating.Tokenizer.Tokens
{
    public class LiteralToken : IToken
    {
        private readonly string _literal;

        public LiteralToken(string literal)
        {
            _literal = literal;
        }

        public string Literal
        {
            get { return _literal; }
        }

        public override string ToString()
        {
            return Literal;
        }

        public bool Equals(LiteralToken other)
        {
            if (ReferenceEquals(null, other))
            {
                return false;
            }
            if (ReferenceEquals(this, other))
            {
                return true;
            }
            return Equals(other._literal, _literal);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj))
            {
                return false;
            }
            if (ReferenceEquals(this, obj))
            {
                return true;
            }
            if (obj.GetType() != typeof (LiteralToken))
            {
                return false;
            }
            return Equals((LiteralToken) obj);
        }

        public override int GetHashCode()
        {
            return (_literal != null ? _literal.GetHashCode() : 0);
        }
    }
}